package com.pet.system.security.jwt;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * jwt 配置
 *
 * @author Centaurea
 */
@Data
@ConfigurationProperties(prefix = "centaurea.permission.jwt")
public class JwtProperties {
  /** 密钥 */
  private String secret;
  /** 有效期(单位：秒), 默认 1小时 */
  private Integer expire;
  /** header中取值name */
  private String headerName;

  public Integer getExpire() {
    return (expire == null || expire < 0L) ? 3600 : expire;
  }

  public String getHeaderName() {
    return StringUtils.isEmpty(headerName) ? "Authorization" : headerName;
  }
}
